package com.ruoyi.system.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.system.domain.ViewRoomrec;
import com.ruoyi.system.service.IViewRoomrecService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * VIEWController
 * 
 * @author ruoyi
 * @date 2021-12-04
 */
@RestController
@RequestMapping("/roomrec")
public class ViewRoomrecController extends BaseController
{
    @Autowired
    private IViewRoomrecService viewRoomrecService;

    /**
     * 查询VIEW列表
     */
    @RequiresPermissions("system:roomrec:list")
    @GetMapping("/list")
    public TableDataInfo list(ViewRoomrec viewRoomrec)
    {
        startPage();
        List<ViewRoomrec> list = viewRoomrecService.selectViewRoomrecList(viewRoomrec);
        return getDataTable(list);
    }

    /**
     * 导出VIEW列表
     */
    @RequiresPermissions("system:roomrec:export")
    @Log(title = "VIEW", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ViewRoomrec viewRoomrec)
    {
        List<ViewRoomrec> list = viewRoomrecService.selectViewRoomrecList(viewRoomrec);
        ExcelUtil<ViewRoomrec> util = new ExcelUtil<ViewRoomrec>(ViewRoomrec.class);
        util.exportExcel(response, list, "VIEW数据");
    }

    /**
     * 获取VIEW详细信息
     */
    @RequiresPermissions("system:roomrec:query")
    @GetMapping(value = "/{roomId}")
    public AjaxResult getInfo(@PathVariable("roomId") Long roomId)
    {
        return AjaxResult.success(viewRoomrecService.selectViewRoomrecByRoomId(roomId));
    }

    /**
     * 新增VIEW
     */
    @RequiresPermissions("system:roomrec:add")
    @Log(title = "VIEW", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ViewRoomrec viewRoomrec)
    {
        return toAjax(viewRoomrecService.insertViewRoomrec(viewRoomrec));
    }

    /**
     * 修改VIEW
     */
    @RequiresPermissions("system:roomrec:edit")
    @Log(title = "VIEW", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ViewRoomrec viewRoomrec)
    {
        return toAjax(viewRoomrecService.updateViewRoomrec(viewRoomrec));
    }

    /**
     * 删除VIEW
     */
    @RequiresPermissions("system:roomrec:remove")
    @Log(title = "VIEW", businessType = BusinessType.DELETE)
	@DeleteMapping("/{roomIds}")
    public AjaxResult remove(@PathVariable Long[] roomIds)
    {
        return toAjax(viewRoomrecService.deleteViewRoomrecByRoomIds(roomIds));
    }
}
